package Logicamente;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Window;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.GridBagLayout;

import javax.swing.JComboBox;

import java.awt.GridBagConstraints;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;

import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Toolkit;

public class VentanaCrearPartida2 extends JFrame {

	private JPanel contentPane;
	private VentanaCrearPartidaA ventanaPadre;
	private JComboBox comboBox;
	
	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the frame.
	 */
	public VentanaCrearPartida2(VentanaCrearPartidaA v) {
		setIconImage(Toolkit.getDefaultToolkit().getImage(VentanaCrearPartida2.class.getResource("/Imagenes/L.png")));
		setTitle("Logicamente");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		ventanaPadre = v;
		setBounds(100, 100, 450, 300);
		contentPane = new JPanelConFondo("/Imagenes/fondo.jpg");
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel panel = new JPanelConFondo("/Imagenes/fondo_t.png");
		contentPane.add(panel, BorderLayout.CENTER);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[]{20, 200, 100, 20, 0};
		gbl_panel.rowHeights = new int[]{20, 0, 0, 0, 0, 20, 0};
		gbl_panel.columnWeights = new double[]{100.0, 50.0, 50.0, 100.0, Double.MIN_VALUE};
		gbl_panel.rowWeights = new double[]{100.0, 20.0, 20.0, 0.0, 20.0, 100.0, Double.MIN_VALUE};
		panel.setLayout(gbl_panel);
		
		comboBox = new JComboBox();
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"Cantidad de preguntas maxima", "3", "4", "5", "6", "7", "8", "9", "10"}));
		GridBagConstraints gbc_comboBox = new GridBagConstraints();
		gbc_comboBox.gridwidth = 2;
		gbc_comboBox.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox.gridx = 1;
		gbc_comboBox.gridy = 1;
		panel.add(comboBox, gbc_comboBox);
		
		JButton btnSeleccionarPreguntas = new JButton("Seleccionar preguntas");
		btnSeleccionarPreguntas.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				actionSeleccionar(e);
			}

		});
		GridBagConstraints gbc_btnSeleccionarPreguntas = new GridBagConstraints();
		gbc_btnSeleccionarPreguntas.anchor = GridBagConstraints.WEST;
		gbc_btnSeleccionarPreguntas.insets = new Insets(0, 0, 5, 5);
		gbc_btnSeleccionarPreguntas.gridx = 1;
		gbc_btnSeleccionarPreguntas.gridy = 2;
		panel.add(btnSeleccionarPreguntas, gbc_btnSeleccionarPreguntas);
		
		JLabel lblVolver = new JLabel("Volver");
		lblVolver.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
		GridBagConstraints gbc_lblVolver = new GridBagConstraints();
		gbc_lblVolver.anchor = GridBagConstraints.WEST;
		gbc_lblVolver.insets = new Insets(0, 0, 5, 5);
		gbc_lblVolver.gridx = 1;
		gbc_lblVolver.gridy = 3;
		panel.add(lblVolver, gbc_lblVolver);
		
		JLabel lblCrear = new JLabel("Crear");
		lblCrear.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
		GridBagConstraints gbc_lblCrear = new GridBagConstraints();
		gbc_lblCrear.anchor = GridBagConstraints.SOUTH;
		gbc_lblCrear.insets = new Insets(0, 0, 5, 5);
		gbc_lblCrear.gridx = 2;
		gbc_lblCrear.gridy = 3;
		panel.add(lblCrear, gbc_lblCrear);
		
		JButton button = new JButton("");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				actionCrear(e);
			}

		});
		
		JButton btnVolver = new JButton("");
		btnVolver.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				actionVolver(e);
			}
		});
		btnVolver.setIcon(new ImageIcon(VentanaCrearPartida2.class.getResource("/Imagenes/boton_volver_f.png")));
		GridBagConstraints gbc_btnVolver = new GridBagConstraints();
		gbc_btnVolver.anchor = GridBagConstraints.WEST;
		gbc_btnVolver.insets = new Insets(0, 0, 5, 5);
		gbc_btnVolver.gridx = 1;
		gbc_btnVolver.gridy = 4;
		panel.add(btnVolver, gbc_btnVolver);
		button.setIcon(new ImageIcon(VentanaCrearPartida2.class.getResource("/Imagenes/boton_adelante_f.png")));
		GridBagConstraints gbc_button = new GridBagConstraints();
		gbc_button.insets = new Insets(0, 0, 5, 5);
		gbc_button.gridx = 2;
		gbc_button.gridy = 4;
		panel.add(button, gbc_button);
	}
	
	protected void actionSeleccionar(ActionEvent e) {
		VentanaSeleccionarPreguntas v = new VentanaSeleccionarPreguntas(4);
		v.setLocationRelativeTo(null);
		v.setVisible(true);			
	}

	protected void actionCrear(ActionEvent e) {
		
		
	}
	
	protected void actionVolver(ActionEvent e) {
		ventanaPadre.setVisible(true);
		this.setVisible(false);
		this.hide();
		
	}

}
